package com.runchinaup.smartbelt.domian;

/**
 * 设置闹钟使能
 */

public class AlarmCanData extends BaseData {

    //闹钟使能
    private byte makeOne = (byte) 0xa1;
    private byte makeTwo = (byte) 0x5a;
    private byte makethree = (byte) 0x08;
    private byte makeFour = (byte) 0x05;

    private boolean oneAlarm = false;
    private boolean twoAlarm = false;
    private boolean threeAlarm = false;

    public boolean isOneAlarm() {
        return oneAlarm;
    }

    public void setOneAlarm(boolean oneAlarm) {
        this.oneAlarm = oneAlarm;
    }

    public boolean isTwoAlarm() {
        return twoAlarm;
    }

    public void setTwoAlarm(boolean twoAlarm) {
        this.twoAlarm = twoAlarm;
    }

    public boolean isThreeAlarm() {
        return threeAlarm;
    }

    public void setThreeAlarm(boolean threeAlarm) {
        this.threeAlarm = threeAlarm;
    }

    //闹钟使能
    public byte[] canAlarm() {
        byte canOneAlarm = 0;
        if (oneAlarm) {
            canOneAlarm = (byte) 0xff;
        }
        byte canTwoAlarm = 0;
        if (twoAlarm) {
            canTwoAlarm = (byte) 0xff;
        }
        byte canThreeAlarm = 0;
        if (threeAlarm) {
            canThreeAlarm = (byte) 0xff;
        }

        //四个报头 + 总开关 + 闹钟0使能 + 闹钟1使能 + 闹钟2使能 + 校验码
        byte[] setValue = new byte[]{
                makeOne,
                makeTwo,
                makethree,
                makeFour,
                (byte) 0xff,
                canOneAlarm,
                canTwoAlarm,
                canThreeAlarm,
                0
        };

        setValue[setValue.length - 1] = CountCheckCode(setValue);
        return setValue;
    }

    //返回是否有闹钟被开启
    public boolean alarmIsOpen() {
        if (oneAlarm || twoAlarm || threeAlarm) {
            return true;
        }
        return false;
    }

    //读取闹钟使能
    public byte[] getAlarmCan() {
        byte[] setValue = new byte[]{
                makeOne,
                makeTwo,
                0x04,
                0x50,
                (byte) 0xb1
        };
        return setValue;
    }

}
